/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

/**
 *
 * @author DucThien
 */
public class ServletHelper {
    public static String filter(String input) { 
        StringBuilder filtered = new StringBuilder(input.length()); 
        char c; 
        for (int i = 0; i < input.length(); i++) { 
            c = input.charAt(i); 
            switch (c) { 
                case '<': filtered.append("&lt;");break; 
                case '>': filtered.append("&gt;");break; 
                case '"': filtered.append("&quot;");break; 
                case '&': filtered.append("&amp;"); break; 
                default: filtered.append(c); 
            } 
        } 
        return (filtered.toString()); 
    }
}
